//
//  JiangDaoViewController.m
//  JiuKuGospel
//
//  Created by jiukuyinyue on 16/8/3.
//  Copyright (c) 2016年 JiuKuForApp. All rights reserved.
//

#import "JiangDaoViewController.h"
//#import "ShiGeCustomCollectionViewCell.h"
//#import "JiangDaoListViewController.h"
//#import "ShiGeCustomTableViewCell.h"
//#import "JiangYuanViewController.h"
//#import "JiGouViewController.h"

#define CELL_JIAN_JU 15

@interface JiangDaoViewController ()<UICollectionViewDataSource, UICollectionViewDelegate, UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong)NSMutableArray * jiangdaoArr;
@property (nonatomic, strong)UICollectionView * jiangDaoCollectionView;
@property (nonatomic, strong)UIView * jiangDaoMusicView;


@property (nonatomic, strong)UISegmentedControl * segment;

@property (nonatomic, strong)UISegmentedControl * segmentMusicType;
@property (nonatomic, strong)UITableView * jiangDaoTab;

@property (nonatomic, strong)UIView * headerView;

@property (nonatomic, assign)NSInteger pageNum;

@property (nonatomic, strong)NSMutableArray * hotArr;
@property (nonatomic, strong)NSMutableArray * jiangYuanArr;
@property (nonatomic, strong)NSMutableArray * jiGouArr;
@property (nonatomic, strong)NSMutableArray * leiBieArr;
@property (nonatomic, strong)NSMutableArray * dataArr;

//@property (nonatomic, strong)JKShareCollectDownView * selectAddView;    //分享下载多功能

@end

@implementation JiangDaoViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    self.navigationController.navigationBar.hidden = NO;
    
//    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
//    appDelegate.playSongView.hidden = NO;
//    [appDelegate.window bringSubviewToFront:appDelegate.playSongView];
    [TheHomeManager shareTheHomeManager].nowViewController = self;
    
    
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationController.navigationBar.hidden = NO;
    
    self.view.backgroundColor = [UIColor whiteColor];
    //导航栏颜色
    self.navigationController.navigationBar.barTintColor = JK_HUISE_LINE_COLOR;
    //导航栏字体颜色
    self.navigationItem.title = @"讲道";

    self.pageNum = 1;
    
    NSArray * itemArr = [NSArray arrayWithObjects:@"视频", @"音频", nil];
    self.segment = [[UISegmentedControl alloc] initWithItems:itemArr];
    _segment.frame = CGRectMake((self.view.width-170)/2, 27, 170, 30);
    _segment.selectedSegmentIndex = 0;
    _segment.tintColor = JK_RED_COLOR;
    [_segment addTarget:self action:@selector(changeUI:) forControlEvents:UIControlEventValueChanged];
    self.navigationItem.titleView = _segment;
    _segment.userInteractionEnabled = YES;
    self.navigationItem.titleView.userInteractionEnabled = YES;

    
    [self setupUI];
//    [self loadJiangDaoData];
    
}


- (void)setupUI
{
    CGFloat width = (self.view.width-4*CELL_JIAN_JU)/3;
    UICollectionViewFlowLayout * flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(width, width+25+10);
    flowLayout.minimumInteritemSpacing = 10;
    flowLayout.minimumLineSpacing = 0;
    flowLayout.sectionInset = UIEdgeInsetsMake(0, CELL_JIAN_JU, 10, CELL_JIAN_JU);
    self.jiangDaoCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, CELL_JIAN_JU, self.view.width, self.view.height-15-60) collectionViewLayout:flowLayout];
    _jiangDaoCollectionView.delegate = self;
    _jiangDaoCollectionView.dataSource = self;
    _jiangDaoCollectionView.backgroundColor = [UIColor whiteColor];
//    [_jiangDaoCollectionView registerClass:[ShiGeCustomCollectionViewCell class] forCellWithReuseIdentifier:@"collectionViewCell"];
    
    [self.view addSubview:_jiangDaoCollectionView];
    
    
    self.jiangDaoMusicView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
    [self.view addSubview:_jiangDaoMusicView];
    
    NSArray * itemArrs = [NSArray arrayWithObjects:@"热门", @"讲员", @"机构", @"类别", nil];
    self.segmentMusicType = [[UISegmentedControl alloc] initWithItems:itemArrs];
    _segmentMusicType.frame = CGRectMake(20, 10+64, _jiangDaoMusicView.width-2*20, 40);
    _segmentMusicType.selectedSegmentIndex = 0;
    _segmentMusicType.tintColor = JK_RED_COLOR;
    _segmentMusicType.userInteractionEnabled = YES;
    [_segmentMusicType addTarget:self action:@selector(changeJiangDao:) forControlEvents:UIControlEventValueChanged];
    [self.jiangDaoMusicView addSubview:_segmentMusicType];
    _jiangDaoMusicView.hidden = YES;

    self.jiangDaoTab = [[UITableView alloc] initWithFrame:CGRectMake(0, _segmentMusicType.bottom+5, _jiangDaoMusicView.width, _jiangDaoMusicView.height-_segmentMusicType.bottom-60) style:UITableViewStylePlain];
    _jiangDaoTab.delegate = self;
    _jiangDaoTab.dataSource = self;
    [self.jiangDaoMusicView addSubview:_jiangDaoTab];
    
//    UITapGestureRecognizer * randomTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(randomPlaySongs)];
//    self.headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 40)];
//    [_headerView addGestureRecognizer:randomTap];
//    //随机
//    UIView * randomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _headerView.height, _headerView.height)];
//    [_headerView addSubview:randomView];
//    UIImageView * tempImageView = [[UIImageView alloc] initWithFrame:CGRectMake((randomView.width-20)/2, (randomView.height-20)/2, 20, 20)];
//    tempImageView.image = [UIImage imageNamed:@"randomStop@3x.png"];
//    [randomView addSubview:tempImageView];
//    UILabel * tempLabel = [[UILabel alloc] initWithFrame:CGRectMake(randomView.right, 0, self.view.width-100, _headerView.height)];
//    tempLabel.text = @"随机播放全部";
//    tempLabel.font = FONT_16;
//    [_headerView addSubview:tempLabel];
//    //多选
//    UITapGestureRecognizer * moreSelectTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(moreSelectTap)];
//    UIView * moreSelectView = [[UIView alloc] initWithFrame:CGRectMake(self.view.width-60, 0, 60, _headerView.height)];
//    [moreSelectView addGestureRecognizer:moreSelectTap];
////    [_headerView addSubview:moreSelectView];
//    //46X38  moreSelect@3x.png
//    UIImageView * moreSelectImageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 12, 20, 16)];
//    moreSelectImageV.userInteractionEnabled = YES;
//    moreSelectImageV.image = [UIImage imageNamed:@"moreSelect@3x.png"];
//    [moreSelectView addSubview:moreSelectImageV];
//    UILabel * moreSelectLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, 5, 30, 30)];
//    moreSelectLabel.text = @"多选";
//    moreSelectLabel.font = FONT_14;
//    [moreSelectView addSubview:moreSelectLabel];
//    
//    
//    //下划线
//    UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(0, _headerView.height-0.5, _headerView.width, 0.5)];
//    lineView.backgroundColor = [UIColor lightGrayColor];
//    [_headerView addSubview:lineView];
////    _jiangDaoTab.tableHeaderView = _headerView;
//
//    //cell分割线顶头
//    if ([self.jiangDaoTab respondsToSelector:@selector(setSeparatorInset:)]) {
//        [self.jiangDaoTab setSeparatorInset: UIEdgeInsetsZero];
//    }
//    if ([self.jiangDaoTab respondsToSelector:@selector(setLayoutMargins:)]) {
//        [self.jiangDaoTab setLayoutMargins: UIEdgeInsetsZero];
//    }
//    [self setExtraCellLineHidden:_jiangDaoTab];
//    
//    __block JiangDaoViewController * jiangDVC = self;
//    [_jiangDaoTab addHeaderWithCallback:^{
//        _pageNum = 1;
//        if (_segmentMusicType.selectedSegmentIndex == 0) {
//            [jiangDVC loadMusicJiangDaoData:@"hotmusic"];
//        }
//        if (_segmentMusicType.selectedSegmentIndex == 1) {
//            [jiangDVC loadMusicJiangDaoData:@"jiangyuan"];
//        }
//        if (_segmentMusicType.selectedSegmentIndex == 2) {
//            [jiangDVC loadMusicJiangDaoData:@"jigou"];
//        }
//        if (_segmentMusicType.selectedSegmentIndex == 3) {
//            [jiangDVC loadMusicJiangDaoData:@"leibie"];
//        }
//
//    }];
//    
//    [_jiangDaoTab addFooterWithCallback:^{
//        if (jiangDVC.segmentMusicType.selectedSegmentIndex == 0) {
//            _pageNum = (self.hotArr.count+29)/30+1;
//            [jiangDVC loadMusicJiangDaoData:@"hotmusic"];
//        }
//        if (jiangDVC.segmentMusicType.selectedSegmentIndex == 1) {
//            _pageNum = (self.jiangYuanArr.count+29)/30+1;
//            [jiangDVC loadMusicJiangDaoData:@"jiangyuan"];
//            
//        }
//        if (jiangDVC.segmentMusicType.selectedSegmentIndex == 2) {
//            _pageNum = (self.jiGouArr.count+29)/30+1;
//            [jiangDVC loadMusicJiangDaoData:@"jigou"];
//            
//        }
//        if (jiangDVC.segmentMusicType.selectedSegmentIndex == 3) {
//            _pageNum = (self.hotArr.count+29)/30+1;
//            [jiangDVC loadMusicJiangDaoData:@"leibie"];
//            
//        }
//
//    }];
    
    //分享下载多功能
//    self.selectAddView = [[JKShareCollectDownView alloc] initWithFrame:CGRectMake(self.view.width-180, 50, 170, 28)];
//    [_selectAddView.downBtn addTarget:self action:@selector(downClick:) forControlEvents:UIControlEventTouchUpInside];
//    [_selectAddView.collectBtn addTarget:self action:@selector(colletcClick:) forControlEvents:UIControlEventTouchUpInside];
//    [_selectAddView.shareBtn addTarget:self action:@selector(shareClick:) forControlEvents:UIControlEventTouchUpInside];

}
//
//- (void)setExtraCellLineHidden: (UITableView *)tableView
//{
//    UIView *view = [[UIView alloc]init];
//    view.backgroundColor = [UIColor clearColor];
//    [tableView setTableFooterView:view];
//}
//
//- (void)loadJiangDaoData
//{
//    MBProgressHUD *hud=[MBProgressHUD showHUDAddedTo:self.view animated:YES];
//    hud.mode=MBProgressHUDAnimationFade;//枚举类型不同的效果
//
//    //视频web
//    NSDictionary * dic = @{@"type":@"jiangdao", @"parentid":@"0"};
//    [HttpTool postWithURL:kBasePostFuyin params:dic success:^(id json) {
//        [self hiddenMBAction];
//        NSArray * arr = [json objectForKey:@"data"];
//        [self.jiangdaoArr addObjectsFromArray:arr];
//        [_jiangDaoCollectionView reloadData];
//        
//    } failure:^(NSError *error) {
//        [self hiddenMBAction];
//
//    }];
//   
//}
//
//- (void)loadMusicJiangDaoData:(NSString *)type
//{
//    MBProgressHUD *hud=[MBProgressHUD showHUDAddedTo:self.view animated:YES];
//    hud.mode=MBProgressHUDAnimationFade;//枚举类型不同的效果
//
//    //音频
//    NSDictionary * dic = @{@"type":type, @"page":[NSString stringWithFormat:@"%ld", _pageNum], @"size":COUNT};
//    [HttpTool postWithURL:kBasePostFuyin params:dic success:^(id json) {
//        [self hiddenMBAction];
//        if ([[json objectForKey:@"data"] isKindOfClass:[NSArray class]]) {
//            JKSongsMessResult * results = [[JKSongsMessResult alloc] init];
//            results.data = [json valueForKey:@"data"];
//            NSArray * arr = [JKSongsMessStatus objectArrayWithKeyValuesArray:results.data];
//
//            if (_segmentMusicType.selectedSegmentIndex == 0) {
//                if (_pageNum == 1) {
//                    [self.hotArr removeAllObjects];
//                }
//                [self.hotArr addObjectsFromArray:arr];
//                [self.dataArr removeAllObjects];
//                [self.dataArr addObjectsFromArray:_hotArr];
//                
//            }
//            
//            if (_segmentMusicType.selectedSegmentIndex == 1) {
//                if (_pageNum == 1) {
//                    [self.jiangYuanArr removeAllObjects];
//                }
//                [self.jiangYuanArr addObjectsFromArray:arr];
//                [self.dataArr removeAllObjects];
//                [self.dataArr addObjectsFromArray:_jiangYuanArr];
//            }
//
//            if (_segmentMusicType.selectedSegmentIndex == 2) {
//                if (_pageNum == 1) {
//                    [self.jiGouArr removeAllObjects];
//                }
//                [self.jiGouArr addObjectsFromArray:arr];
//                [self.dataArr removeAllObjects];
//                [self.dataArr addObjectsFromArray:_jiGouArr];
//            }
//
//            if (_segmentMusicType.selectedSegmentIndex == 3) {
//                if (_pageNum == 1) {
//                    [self.leiBieArr removeAllObjects];
//                }
//                [self.leiBieArr addObjectsFromArray:arr];
//                [self.dataArr removeAllObjects];
//                [self.dataArr addObjectsFromArray:_leiBieArr];
//            }
//            [self.jiangDaoTab reloadData];
//
//        }
//
//        [_jiangDaoTab headerEndRefreshing];
//        [_jiangDaoTab footerEndRefreshing];
//
//    } failure:^(NSError *error) {
//        [_jiangDaoTab headerEndRefreshing];
//        [_jiangDaoTab footerEndRefreshing];
//        [self hiddenMBAction];
//
//    }];
//
//}
//
//
//- (void)changeJiangDao:(UISegmentedControl *)segment
//{
//    [self.dataArr removeAllObjects];
//    [self.jiangDaoTab reloadData];
//    if (segment.selectedSegmentIndex == 0) {
//        self.jiangDaoTab.tableHeaderView = _headerView;
//        if (self.hotArr.count == 0) {   //加载热门
//            [self loadMusicJiangDaoData:@"hotmusic"];
//        }else{
//            [self.dataArr addObjectsFromArray:self.hotArr];
//            [self.jiangDaoTab reloadData];
//        }
//        NSLog(@"热门");
//    }else{
//        self.jiangDaoTab.tableHeaderView = nil;
//        [self.jiangDaoTab reloadData];
//    }
//    
//    if (segment.selectedSegmentIndex == 1) {
//        if (self.jiangYuanArr.count == 0) { //加载讲员
//            [self loadMusicJiangDaoData:@"jiangyuan"];
//        }else{
//            [self.dataArr addObjectsFromArray:self.jiangYuanArr];
//            [self.jiangDaoTab reloadData];
//        }
//        NSLog(@"讲员");
//    }
//    if (segment.selectedSegmentIndex == 2) {
//        if (self.jiGouArr.count == 0) { //加载机构
//            [self loadMusicJiangDaoData:@"jigou"];
//        }else{
//            [self.dataArr addObjectsFromArray:self.jiGouArr];
//            [self.jiangDaoTab reloadData];
//        }
//        NSLog(@"机构");
//    }
//    if (segment.selectedSegmentIndex == 3) {
//        if (self.leiBieArr.count == 0) {    //加载类别
//            [self loadMusicJiangDaoData:@"fenlei"];
//        }else{
//            [self.dataArr addObjectsFromArray:self.leiBieArr];
//            [self.jiangDaoTab reloadData];
//        }
//        NSLog(@"类别");
//    }
//
//}
- (void)hiddenMBAction{
    [MBProgressHUD hideHUDForView:self.view animated:YES];
}

- (void)changeUI:(UISegmentedControl *)segment
{
    [self hiddenMBAction];
    if (_segment.selectedSegmentIndex == 0) {
        _jiangDaoMusicView.hidden = YES;
        _jiangDaoCollectionView.hidden = NO;
//        _shigeTableView.hidden = YES;
//        _shigeCollectionView.hidden = NO;
//        [self.cellDataArr removeAllObjects];
//        [self.cellDataArr addObjectsFromArray:_shigeArr];
//        [_shigeCollectionView reloadData];
    }
    
    if (_segment.selectedSegmentIndex == 1) {
        _jiangDaoCollectionView.hidden = YES;
        _jiangDaoMusicView.hidden = NO;
        if (self.hotArr.count == 0) {
            
//            [self loadMusicJiangDaoData:@"hotmusic"];
        }
    }
    //1600 1400 1400
    //1100 2700 3800
}
//
//
//- (void)leftBtnAction
//{
//    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
//    appDelegate.playSongView.hidden = YES;
//
//    [self.navigationController popViewControllerAnimated:YES];
//}
//
//- (void)didReceiveMemoryWarning {
//    [super didReceiveMemoryWarning];
//    // Dispose of any resources that can be recreated.
//}
//
//- (void)randomPlaySongs
//{
//    [TheHomeManager shareTheHomeManager].shengjPlayBool = 0;
//    
//    NSInteger tempIndex = random()%_hotArr.count;
//    JKSongsMessStatus * status = [_hotArr objectAtIndex:tempIndex];
//    
//    PlayViewController * playVC = [[PlayViewController alloc] init];
//    playVC.localPlayBool = NO;
//    playVC.songIndex = tempIndex;
//    playVC.songListArr = _hotArr;
//    playVC.listNameStr = status.album;
//    playVC.playStyleNum = 1;
//    
//    playVC.imageUrl = [NSString stringWithFormat:@"%@", status.image];
//    [playVC viewDidLoad];
//    [playVC playMusicWithIndex:tempIndex];
//    
//    [self presentViewController:playVC animated:YES completion:nil];
//    
//    NSLog(@"随机播放全部");
//}
//
//
//#pragma mark - 下载,分享功能
//- (void)downClick:(UIButton *)btn
//{
//    JKSongsMessStatus * status = [self.dataArr objectAtIndex:[[TheHomeManager shareTheHomeManager].selectIndex integerValue]];
//    //单接口分享微信朋友圈
//    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
//    [appDelegate shareMusic:status type:1];
//    NSLog(@"分享");
//}
//- (void)colletcClick:(UIButton *)btn
//{
//    JKSongsMessStatus * status = [self.dataArr objectAtIndex:[[TheHomeManager shareTheHomeManager].selectIndex integerValue]];
//    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
//    [appDelegate shareMusic:status type:2];
//    
//    //单接口分享微信好友
//    NSLog(@"分享");
//}
//- (void)shareClick:(UIButton *)btn
//{
//    JKSongsMessStatus * status = [self.dataArr objectAtIndex:[[TheHomeManager shareTheHomeManager].selectIndex integerValue]];
//    NSString * imageStr = nil;
//    if (status.image300.length > 0) {
//        imageStr = status.image300;
//    }else{
//        imageStr = status.image;
//    }
//    [self willDownloadMusic:status.wma songName:status.MusicName singerName:status.singerName pic:imageStr pic300:imageStr pic1:imageStr zhuanjiName:status.album songTime:status.wma_time songID:status.songID nclassID:nil zhuanjiID:nil];
//    
//    
//    NSLog(@"开始执行下载事件 第%@个", [TheHomeManager shareTheHomeManager].selectIndex);
//    
//    NSLog(@"下载");
//}
//- (void)willDownloadMusic:(NSString *)wmastr songName:(NSString *)nameStr singerName:(NSString *)singerName pic:(NSString *)pic pic300:(NSString *)pic300 pic1:(NSString *)pic1 zhuanjiName:(NSString *)zjName songTime:(NSString *)songTime songID:(NSString *)songID nclassID:(NSString *)nclassID zhuanjiID:(NSString *)zhaunjiID
//{
//    MBProgressHUD*hud=[MBProgressHUD showHUDAddedTo:self.view animated:YES];
//    hud.mode=MBProgressHUDModeText;//枚举类型不同的效果
//    
//    hud.labelText=@"下载已开始";
//    [self performSelector:@selector(hiddenMBAction) withObject:nil afterDelay:0.5];
//    
//    [[FilesDownManage sharedFilesDownManage] downFileUrl:wmastr filename:nameStr singerName:singerName pic:pic pic300:nil pic1:nil zhuanjiName:zjName songTime:songTime songID:songID nclassID:nclassID zhuanjiID:zhaunjiID filetarget:@"mp3"];
//    
//    //    UINavigationController * myDownLoadNav = [[UINavigationController alloc] initWithRootViewController:[MyDownLoadViewController shareJKDownVC]];
//    //    [self presentViewController:myDownLoadNav animated:YES completion:nil];
//    
//}
//- (void)hiddenMBAction
//{
//    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
//}
//#pragma mark - 集合视图
//
//- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
//{
//    return self.jiangdaoArr.count;
//}
//
//- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
//{
//    ShiGeCustomCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"collectionViewCell" forIndexPath:indexPath];
//    cell.shigeDic = [self.jiangdaoArr objectAtIndex:indexPath.row];
//    
////    if ([[[self.jiangdaoArr objectAtIndex:indexPath.row] objectForKey:@"id"] isEqualToString:[TheHomeManager shareTheHomeManager].selectShiGeID]) {
////        cell.numLabel.textColor = JK_RED_COLOR;
////        [cell addSubview:_selectView];
////    }
//    
//    
//    return cell;
//}
//
//- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
//{
//    NSDictionary * dic = [self.jiangdaoArr objectAtIndex:indexPath.row];
//    JiangDaoListViewController * listVC = [[JiangDaoListViewController alloc] init];
//    listVC.titleStr = [dic objectForKey:@"title"];
//    listVC.listID = [dic objectForKey:@"id"];
//    listVC.headerImageUrl = [dic objectForKey:@"pic"];
//    [self.navigationController pushViewController:listVC animated:YES];
//}
//
//
//
//#pragma mark - 讲道TabDelegate
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//
//{
//    return self.dataArr.count;
//}
//
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    JKSongsMessStatus * status = [self.dataArr objectAtIndex:indexPath.row];
//    if ([[TheHomeManager shareTheHomeManager].selectID isEqualToString:status.songID] && self.segmentMusicType.selectedSegmentIndex == 0) {
//        return 80;
//    }
//    
//    return 60;
//}
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//{
////    if (self.segmentMusicType.selectedSegmentIndex == 0) {      //热门讲道
//        static NSString * cellStr = @"shigeCustomCell";
//        ShiGeCustomTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellStr];
//        if (!cell) {
//            cell = [[ShiGeCustomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellStr];
//            cell.width = self.view.width;
//            cell.height = 60;
//        }
//        if (self.dataArr.count == 0) {
//            return cell;
//        }
//        if (_segment.selectedSegmentIndex == 0) {
//            return cell;
//        }
//        cell.target = self;
//        cell.action = @selector(cellDownLoadActionIndex:);
//        cell.index = indexPath.row;
//        JKSongsMessStatus * status = [self.dataArr objectAtIndex:indexPath.row];
//        if ([[TheHomeManager shareTheHomeManager].selectID isEqualToString:status.songID]) {
//            cell.height = 80;
//        }else{
//            cell.height = 60;
//        }
//        cell.status = status;
//        cell.numLabel.text = [NSString stringWithFormat:@"%ld", indexPath.row+1];
//        if ([[TheHomeManager shareTheHomeManager].selectID isEqualToString:status.songID]) {
//            [cell.allView addSubview:_selectAddView];
//        }
//    
//    
//    if (self.segmentMusicType.selectedSegmentIndex == 1) {  //讲员
//        cell.songNameLabel.text = status.singerName;
//        cell.zjNameLabel.text = [NSString stringWithFormat:@"%@个专辑%@篇讲道", status.total_album, status.total_song];
//        cell.downLoadView.hidden = YES;
//    }
//    if (self.segmentMusicType.selectedSegmentIndex == 2) {  //机构
//        cell.zjNameLabel.text = [NSString stringWithFormat:@"%@个专辑", status.total_album];
//        cell.downLoadView.hidden = YES;
//    }
//    
//    if (self.segmentMusicType.selectedSegmentIndex == 3) {
//        cell.zjNameLabel.text = [NSString stringWithFormat:@"%@篇讲道", status.total_music];
//        cell.downLoadView.hidden = YES;
//
//    }
//    
//        return cell;
////    }
//    return nil;
//}
//
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//    if (self.segmentMusicType.selectedSegmentIndex == 0) {
//        [TheHomeManager shareTheHomeManager].shengjPlayBool = 0;
//        
//        JKSongsMessStatus * status = [_dataArr objectAtIndex:indexPath.row];
//        
//        PlayViewController * playVC = [[PlayViewController alloc] init];
//        playVC.localPlayBool = NO;
//        playVC.songIndex = indexPath.row;
//        playVC.songListArr = _dataArr;
//        playVC.listNameStr = status.album;
//        
//        [playVC viewDidLoad];
//        [playVC playMusicWithIndex:indexPath.row];
//
//    }
//    
//    
//    if (self.segmentMusicType.selectedSegmentIndex == 1) {
//        JKSongsMessStatus * status = [_dataArr objectAtIndex:indexPath.row];
//        JiangYuanViewController * jiangyuanVC = [[JiangYuanViewController alloc] init];
//        jiangyuanVC.titleStr = status.singerName;
//        jiangyuanVC.typeStr = @"jiangyuan";
//        jiangyuanVC.optStr = @"2";
//        jiangyuanVC.parentId = status.songID;
//        [self.navigationController pushViewController:jiangyuanVC animated:YES];
//    }
//    
//    if (self.segmentMusicType.selectedSegmentIndex == 2) {
//        JKSongsMessStatus * status = [_dataArr objectAtIndex:indexPath.row];
//        JiGouViewController * jiGouVC = [[JiGouViewController alloc] init];
//        jiGouVC.titleStr = status.MusicName;
//        jiGouVC.typeStr = @"jigou";
//        jiGouVC.optStr = @"2";
//        jiGouVC.parentId = status.songID;
//        [self.navigationController pushViewController:jiGouVC animated:YES];
//    }
//
//    if (self.segmentMusicType.selectedSegmentIndex == 3) {
//        JKSongsMessStatus * status = [_dataArr objectAtIndex:indexPath.row];
//        JiGouViewController * leiBieVC = [[JiGouViewController alloc] init];
//        leiBieVC.titleStr = status.MusicName;
//        leiBieVC.typeStr = @"fenlei";
//        leiBieVC.optStr = @"2";
//        leiBieVC.parentId = status.songID;
//        [self.navigationController pushViewController:leiBieVC animated:YES];
//    }
//
//}
//
//
//- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
//    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
//        
//        [cell setSeparatorInset:UIEdgeInsetsZero];
//        
//    }
//    
//    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
//        
//        [cell setLayoutMargins:UIEdgeInsetsZero];
//    }
//}
//
//
//
//- (void)cellDownLoadActionIndex:(NSString *)index
//{
//    JKSongsMessStatus * statu = [self.hotArr objectAtIndex:[index integerValue]];
//    NSLog(@"%@", statu.MusicName);
//    if ([statu.songID isEqualToString:[TheHomeManager shareTheHomeManager].selectID]) {
//        [TheHomeManager shareTheHomeManager].selectID = @"";
//        [TheHomeManager shareTheHomeManager].selectIndex = @"";
//    }else{
//        [TheHomeManager shareTheHomeManager].selectID = statu.songID;
//        [TheHomeManager shareTheHomeManager].selectIndex = index;
//    }
//    
//    if ([TheHomeManager shareTheHomeManager].selectTab) {
//        //        [[TheHomeManager shareTheHomeManager].selectTab reloadData];
//    }
//    
//    [TheHomeManager shareTheHomeManager].selectTab = _jiangDaoTab;
//    //    _indexSelect = indexPath.row;
//    [_jiangDaoTab reloadData];
//    
//    return;
//    
//    
//}
//
//
//#pragma mark - 懒加载
//- (NSMutableArray *)jiangdaoArr
//{
//    if (_jiangdaoArr == nil) {
//        self.jiangdaoArr = [NSMutableArray array];
//    }
//    return _jiangdaoArr;
//}
//- (NSMutableArray *)hotArr
//{
//    if (_hotArr == nil) {
//        self.hotArr = [NSMutableArray array];
//    }
//    return _hotArr;
//}
//- (NSMutableArray *)jiangYuanArr
//{
//    if (_jiangYuanArr == nil) {
//        self.jiangYuanArr = [NSMutableArray array];
//    }
//    return _jiangYuanArr;
//}
//- (NSMutableArray *)jiGouArr
//{
//    if (_jiGouArr == nil) {
//        self.jiGouArr = [NSMutableArray array];
//    }
//    return _jiGouArr;
//}
//- (NSMutableArray *)leiBieArr
//{
//    if (_leiBieArr == nil) {
//        self.leiBieArr = [NSMutableArray array];
//    }
//    return _leiBieArr;
//}
//- (NSMutableArray *)dataArr
//{
//    if (_dataArr == nil) {
//        self.dataArr = [NSMutableArray array];
//    }
//    return _dataArr;
//}
//

@end
